<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
	<div id="content">
    	888888
    	<p style="width:100px;">jfdkalsfj</p>
        <ul>
        	<li>1</li>
            <li>2</li>
            <li>3</li>
        </ul>
        99999
    </div>
    <script>
	
    	var oDiv=document.getElementById('content');
		
		//console.log(oDiv.innerText);
		
		//firefox不支持
		//oDiv.innerText='hello world';
		
		//获取
		function getInnerText(obj){
			return (typeof obj.textContent=='string')?obj.textContent:obj.innerText;
		};
		
		console.log(getInnerText(oDiv));
		
		//设置
		function setInnerText(obj, text){
			return (typeof obj.textContent=='string')?(obj.textContent=text):(obj.innerText=text);
		};
		setInnerText(oDiv, 'hello world');
		
    </script>
</body>
</html>
